function Set(){
  this.items=[]
  Set.prototype.add = (value)=>{
    if(this.has(value)){
      return false
    }
    this.items[value]=value
    return true
  }
  Set.prototype.has = (value)=>{
    return this.items.hasOwnProperty(value)
  }
  Set.prototype.remove=(value)=>{
    if(!this.has(value)){
      return false
    }
    delete this.items[value]
    return true
  }
  Set.prototype.size=()=>{
    return Object.keys(this.items).length
  }
  Set.prototype.values=()=>{
    return Object.keys(this.items)
  }
  Set.prototype.clear=()=>{
    this.items={}
  }
  Set.prototype.union=(otherSet)=>{
    let unionSet=new Set()
    let values=this.values()
    for(let i=0; i<values.length; i++){
      unionSet.add(values[i])
    }
    values=otherSet.values()
    for(let i=0; i<values.length; i++){
      unionSet.add(values[i])
    }
    return unionSet
  }
  Set.prototype.intersection=(otherSet)=>{
    let intersectionSet=new Set()
    let values=this.values()
    for(let i=0; i<values.length; i++){
      let item=values[i]
      if(otherSet.has(item)){
        intersectionSet.add(item)
      }
    }
    return intersectionSet
  }
  Set.prototype.subset=(otherSet)=>{
    let values=this.values()
    for(let i=0; i<values.length; i++){
      let item=values[i]
      if(!otherSet.has(item)){
        return false
      }
    }
    return true
  }
}

let set1=new Set()
set1.add('abc')
set1.add('bcd')
set1.add('cdd')
set1.values()
set1.has('abc')
set1.remove('abc')
set1.size()
let set2=new Set()
set2.add('aaa')
set2.add('aba')
set2.add('bcd')
let unionSet = set.union(set2)
let intersection = set.intersection(set2)
set.subset(set2)
